<template>
	<div v-if="dialogVisible">
		<el-dialog title="选择音频" :visible.sync="dialogVisible" width="60%" class="uploaddialog">
			<div>
				<div class="uploadtop">
					<span>音频({{total}})</span>
				</div>
				<uploadbottomaudio ref="uploadbottomaudio" v-on:updateAudioTotal="updateAudioTotal"></uploadbottomaudio>
			</div>
			<div slot="footer" class="dialog-footer">
				<el-button @click="dialogVisible = false">取 消</el-button>
				<el-button type="primary" @click="condialogVisible">确 定</el-button>
			</div>
		</el-dialog>
	</div>
</template>

<script>
	import uploadbottomaudio from '@/components/common/uploadbottomaudio.vue';
	export default {
		components: {
			uploadbottomaudio
		},
		data() {
			return {
				dialogVisible: false,
				total: 0,
				isone: true
			}
		},
		methods: {
			condialogVisible() { //确认按钮
				console.log(2222)
				let data = this.$refs.uploadbottomaudio.multipleSelection;
				console.log(data)
				if (this.isone) {
					if (data.length != 1) {
						this.$message.error('只能选择1个音频！');
						return;
					}
					// //this.$parent.$parent.nowitem.dantuimg.src=this.multipleSelection[0].src;
					this.$emit('childByAudioValue', data[0]);
				} else {
					this.$emit('childByAudioValue', data);
				}
				this.dialogVisible = false;
			},
			updateAudioTotal: function(childValue) {
				this.total = childValue;
			}
		}
	}
</script>

<style lang="scss">
	.uploaddialog {
		.el-tree-node:focus>.el-tree-node__content {
			background-color: #409EFF;
			color: white;
		}

		.el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content {
			background-color: #409EFF;
			color: white;
		}

		.uploadtop {
			border-top: 1px solid #eee;
			border-bottom: 1px solid #eee;
			line-height: 50px;
			margin-bottom: 10px;

			span {
				padding-left: 20px;
				padding-right: 10px;
				display: inline-block;
				line-height: 50px;

			}
		}

	}
</style>
